#include <stdio.h>
#include <string.h>

#include "../utility/assert_helper.h"
#include "../utility/file_helper.h"
#include "windows_information.h"
#include "sys_search.h"
#include "windows_manager.h"

Windows_Manager * s_instance = NULL;

I_Windows_Manager * ctreate_windows_manager()
{
	if (NULL == s_instance) {
		s_instance = new Windows_Manager;
	}
	return s_instance;
}

Windows_Manager::Windows_Manager()
{
	windows_info_collection_ = new Windows_Information_Collection;
	if (NULL == windows_info_collection_) return ;
	windows_searcher_ = new Windows_Searcher(*windows_info_collection_);
	if (NULL != windows_searcher_) {
		windows_searcher_->search_all_windows_in_mounted_partition();
	}
	
}

Windows_Manager::~Windows_Manager()
{

}

int Windows_Manager::get_windows_total()
{
	IF_NULL_RETURN_VALUE(windows_info_collection_, 0);
	return windows_info_collection_->get_windows_count();
}

const char * Windows_Manager::get_directory(int wid, Path_Token token)
{
	return NULL;
}

Windows_Edition Windows_Manager::get_windows_version(int wid)
{
	return WINDOWS_UNKNOW;
}

int Windows_Manager::get_windows_users_total(int wid)
{
	return 0;
}

const char * Windows_Manager::get_partition_in_string(int wid)
{
	return NULL;
}
int	Windows_Manager::get_windows_version_and_build_number(int wid, 
int & major_ver, int & minor_ver, int & build_num)
{
	return -1;
}

void * Windows_Manager::local_dynamic_cast(const char * type)
{
	return NULL;
}

void	Windows_Manager::delete_self()
{
	delete this;
}

const Windows_Information * 
Windows_Manager::get_windows_information(int wid) const
{
	IF_NULL_RETURN_VALUE(windows_info_collection_, NULL);
	return windows_info_collection_->get_windows_information(wid);
}

const Windows_Information * 
Windows_Manager::get_windows_information(const char * win_root) const
{
	IF_NULL_RETURN_VALUE(windows_info_collection_, NULL);
	IF_NULL_RETURN_VALUE(win_root, NULL);
	return windows_info_collection_->get_windows_information(win_root);
}
